<template>
	<view class="indexs">
		<view class="header header_wi" :style="'padding-top: ' + navH + 'px;'">
			<view class="header_height" :style="'height:' + gaodu + 'px;line-height:' + gaodu + 'px;top:' + gaodutops + 'px;'">
				<view class="index_h_cont3">
					<view class="index_wenben_img" @tap="jumpzuo"><image :src="imgUrl + '/dzx_img33.png'" mode="widthFix"></image></view>
					<view class="index_wenben">{{ $t('page_goodslist.goodstitle') }}</view>
				</view>
			</view>
			<view class="coloe_title">s</view>
		</view>
		<view class="index_center" :style="'padding-top:' + (navH + 50) + 'px;padding-bottom:130rpx;'">
			<view class="search">
				<view class="search-box">
					<image :src="imgUrl + '/dzx_img38.png'"></image>
					<input type="text" :placeholder="$t('page_goodslist.please_enter_goodsname')"
						@input="searchgoods" @confirm="huiche" />
				</view>
			</view>
			<view class="dizhi_center">
				<view class="dizhi_item1">
					<view class="dizhi_item1_list" v-if="arrlist.length != 0">
						<view class="dizhi_item1_cont" @tap="xuanze" :data-id="item.barcode" v-for="(item, index) in arrlist" :key="index">
							<view class="dizhi_item1_cont_t">
								<view class="dizhi_item1_cont_l">
									<view class="dizhi_item1_cont_t1">
										<text v-if="item.barcode">{{ $t('page_baoguoyg.barcode') }}:{{ item.barcode }} </text>
										<text v-if="item.goods_name">{{ $t('page_baoguoyg.pinming') }}:{{ item.goods_name }} </text>
									</view>
									<view class="dizhi_item1_cont_t1">
										<text v-if="item.goods_name_en">{{ $t('page_baoguoyg.goods_name_en') }}:{{ item.goods_name_en }} </text>
										<text v-if="item.goods_name_jp">{{ $t('page_baoguoyg.goods_name_jp') }}:{{ item.goods_name_jp }} </text>
									</view>
									<view class="dizhi_item1_cont_t2">
										<text v-if="item.brand">{{ $t('page_baoguoyg.brand') }}:{{ item.brand }} </text>
										<text v-if="item.spec">{{ $t('page_baoguoyg.spec') }}:{{ item.spec }} </text>
										<text v-if="item.price">{{ $t('page_baoguoyg.danjia') }}:{{ item.price }} </text>
									</view>
								</view>
							</view>
						</view>
					</view>
					<view class="dizhi_item1_kong" v-else>
						<image :src="imgUrl + '/dzx_img80.png'"></image>
						<text>{{ $t('page_goodslist.nogoodlist') }}</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
// pages/shouye/shouye_zkc/shouye_zkc.js
const app = getApp();

let request = require('../../../utils/require');

export default {
	data() {
		return {
			navH: app.globalData.navHeight,
			gaodu: app.globalData.height,
			gaodutops: app.globalData.top,
			imgUrl: app.globalData.imgUrl,
			arrlist: [],
			search:''
		};
	},
	/**
	 * 生命周期函数--监听页面加载
	 */ 
	onLoad(options) {
		console.log(options,878)
		var that = this;
		that.type = options.type;
		that.search = options.search;
	},
	onShow() {
		var that = this;
		that.getbarcodelist();
	},
	/**
	 * 生命周期函数--监听页面初次渲染完成
	 */
	onReady: function() {},
	/**
	 * 生命周期函数--监听页面隐藏
	 */
	onHide: function() {},
	/**
	 * 生命周期函数--监听页面卸载
	 */
	onUnload: function() {},
	/**
	 * 页面相关事件处理函数--监听用户下拉动作
	 */
	onPullDownRefresh: function() {},
	/**
	 * 页面上拉触底事件的处理函数
	 */
	onReachBottom: function() {},
	/**
	 * 用户点击右上角分享
	 */
	onShareAppMessage: function() {},
	methods: {
		searchgoods(e) {
			this.search = e.detail.value
			if (e.detail.value == '') {
				this.arrlist = []
			}
			this.getbarcodelist();
		},
		huiche() {
			this.getbarcodelist();
		},
		getbarcodelist() {
			var that = this;
			var data = {
				token: uni.getStorageSync('token'),
				search:that.search
			};
			request.post(`index.php?s=/api/page/getbarcodelist&wxapp_id=` + uni.getStorageSync('web_id'), data).then(res => {
				if (res.data.code == 1) {
					that.arrlist= res.data.data.list
					console.log(res, ';ressssssss');
				}
			});
		},

		jumpzuo() {
			uni.navigateBack();
		},

		xuanze(e) {
			console.log(e,9988)
			// #ifdef MP-WEIXIN
				var pages = getCurrentPages();
				var prevPage = pages[pages.length - 2];
				prevPage.data.sku_id = e.currentTarget.dataset.id;
				uni.navigateBack({
					delta: 1
				});
			// #endif
			// #ifdef H5
				var pages = getCurrentPages();
				var prevPage = pages[pages.length - 2];
				prevPage.sku_id  = e.currentTarget.dataset.id;
				uni.navigateBack({
					delta: 1
				});
			// #endif
		}
	}
};
</script>
<style>
@import './goodslist.css';
</style>
